/**
 * 天眼查需要查询的列表中，包含纳税人账户档案号，当时忘记写入mongo里面，为了后续勾稽方便，这里用工具再次更新到里面吧
 * 
 */

/**
数据来自曾科长的excel 2,3 两列，一列档案号，一列名称
  
社会信用代码（纳税人识别号） 	纳税人名称 (不包含这行代码)
91360000669759473R	江西省海济融资租赁股份有限公司
36000000069745377	江西省金融控股集团有限公司
 */

import * as fs from "fs";
import { Driver } from "../db";

let opt = new Driver();

let argc = process.argv.length;
if (argc < 3) {
    console.log("Usage: node tools/tianyancha.js file-name");
    process.exit(1);
}

let fpath = process.argv[argc - 1];
let content = fs.readFileSync(fpath, "utf-8");
let contents = content.split("\n");
for (let i = 0, j = contents.length; i < j; i++) {
    let line_str = contents[i].trim();
    console.log(line_str);
    if (/([^\s]+)\s+(.*)/.test(line_str)) {
        let zhdah = RegExp.$1;
        let nsrmc = RegExp.$2;
        opt.update("qyxx", { title: nsrmc }, { "纳税人账户档案号": zhdah }).then((result) => {
            console.log(zhdah + "<=" + nsrmc + result ? " successful!" : "error");
        }, (err) => {

        });
    }
}
